/**
 * 
 */
package GUI.main.renderers;

import java.awt.Component;
import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import officeserver.users.PersonalInfo;

/**
 * @author mramsey3
 * 
 */
public class UserListRenderer extends JLabel implements ListCellRenderer {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    /*
     * (non-Javadoc)
     * 
     * @see
     * javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing
     * .JList, java.lang.Object, int, boolean, boolean)
     */
    @Override
    public Component getListCellRendererComponent(JList list, Object value,
	    int arg2, boolean isSelected, boolean arg4) {
	PersonalInfo pInfo = (PersonalInfo) value;
	if (pInfo.isActive()) {
	    setText(pInfo.getFirstName() + " " + pInfo.getLastName()
		    + " - Active");
	} else {
	    setText(pInfo.getFirstName() + " " + pInfo.getLastName()
		    + " - Deactivated");
	}
	if (isSelected) {
	    setBackground(list.getSelectionBackground());
	    setForeground(list.getSelectionForeground());
	} else {
	    setBackground(list.getBackground());
	    setForeground(list.getForeground());
	}
	setEnabled(list.isEnabled());
	setFont(list.getFont());
	setOpaque(true);
	setPreferredSize(new Dimension(getWidth(), 40));

	return this;
    }

}
